package com.gugee.tiktok.web.repository;

import com.gugee.tiktok.web.model.mysql.RankingFollowers;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RankingFollowersRepository extends CrudRepository<RankingFollowers,Long> , RankingFollowersExtRepository {

    @Query("SELECT IFNULL(MAX(update_time),0) FROM ranking_followers WHERE ranking_type = :rankingType ORDER BY update_time desc LIMIT 0,1")
    long findUpdateTime(int rankingType);

    @Query("select DISTINCT(belong) from ranking_followers where ranking_type = :rankingType and belong > :startDate ORDER BY belong DESC")
    List<Integer> findBelongDate(int rankingType, int startDate);
}
